package com.flute.haflute.jobbox.communication;

import java.rmi.Remote;
import java.rmi.RemoteException;

/**
 * 主节点通信API
 */
public class MasterCommunicationService {
	private CommunicationServiceFactory serviceFactory;

	public MasterCommunicationService() throws RemoteException {
		serviceFactory = CommunicationServiceFactoryImpl.getInstance();
	}

	/** 获得指定的消息管理器 */
	public Remote getMessager(String messagerName) throws RemoteException {
		return serviceFactory.getMessager(messagerName);
	}

	/** 取得主节点的任务消息通知器 */
	public NotifyService getNotifyService() throws RemoteException {
		return serviceFactory.getNotifier();
	}

	/** 向集群通信平台注入一个消息管理器 */
	public void putMessager(String messagerName, Remote messager)
			throws RemoteException {
		serviceFactory.putMessager(messagerName, messager);
	}

	/** 删除消息器 */
	public Remote removeMessager(String messagerName) throws RemoteException {
		return serviceFactory.removeMessager(messagerName);
	}
}
